//
//  BaseModel.m
//  UI23_基类
//
//  Created by 韩震明 on 15/10/19.
//  Copyright © 2015年 韩震明. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel


/*! 对象模态化 */
+ (NSMutableArray *)baseModelByArr:(NSArray *)arr
{
    // 先初始化容器arr
    NSMutableArray *modelArr = [NSMutableArray array];
    // 遍历数组
    for (NSMutableDictionary *tempDic in arr) {
        
        @autoreleasepool {
            
            // 通过便利构造器来创建对象
            id model = [[self class] baseModelWithDic:tempDic];
            
            [modelArr addObject:model];
        }
        
    }
    return modelArr;
}

/*! 通过多态创建对象 */
+ (instancetype)baseModelWithDic:(NSMutableDictionary *)dic
{
    // 通过多态创建对象
    id model = [[[[self class] alloc] initWithDic:dic] autorelease];
    return model;
}

/*! 自定义kvc赋值 */
- (instancetype)initWithDic:(NSMutableDictionary *)dic
{
    self = [super init];
    if (self) {
        // 进行KVC的赋值
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

/*! 纠错 */
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
    
}





@end
